package com.autumn.xa.common.enums;

/**
 * ClassName: DemoEnums
 *
 * @Description:
 * @Author: wangqiuyang
 * @Date: 2021/12/29 下午2:51
 * History:
 * <author>          <time>          <version>          <desc>
 * wangqiuyang    2021/12/29 下午2:51   @Version 1.0        描述
 */
public enum DemoEnums {

    INIT((byte)1,"新建处罚"),
    UPDATE((byte)2,"处罚变更"),
    ;

    private Byte code;
    private String name;

    DemoEnums(Byte code, String name) {
        this.code = code;
        this.name = name;
    }

    public Byte getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    /**
    * Description: 获取name
    * @param code
    * @return: java.lang.String
    * @author: wangqiuyang
    * @Date: 2021/12/29 下午2:52
    */
    public static String getNameByCode(Byte code){
        if(code==null){
            return null;
        }

        for (DemoEnums p : DemoEnums.values()) {
            if(p.code.equals(code)){
                return p.name;
            }
        }
        return null;
    }

    /**
    * Description: 获取枚举
    * @param code
    * @return: com.autumn.common.enums.DemoEnums
    * @author: wangqiuyang
    * @Date: 2021/12/29 下午2:52
    */
    public static DemoEnums getByCode(Byte code){
        if(code==null){
            return null;
        }

        for (DemoEnums p : DemoEnums.values()) {
            if(p.code.equals(code)){
                return p;
            }
        }
        return null;
    }

}
